<template>
  <div class="white-box">
    <div class="task-one">
      <div class="task-one__item">
        <span class="task-one__label">操作人员用户id：</span>
        <el-input placeholder="请输入用户id" v-model="searchParams.operatorUserId" @keyup.enter.native="handleSearch" clearable></el-input>
      </div>
      <div class="task-one__btn">
        <el-button type="primary" :loading="searchBtnLoading" :icon="Search"
                   @click="handleSearch">搜索</el-button>
      </div>
    </div>
    <div style="margin-bottom: 20px">
      <el-popconfirm :persistent="false" :title="`确定删除勾选的${selectedIds.length}条数据？`" confirm-button-text="确定" cancel-button-text="取消"
                     @confirm="handleDelete(selectedIds)">
        <template #reference>
          <el-button type="danger" plain size="small" :disabled="selectedIds.length == 0">批量删除</el-button>
        </template>
      </el-popconfirm>
    </div>
    <el-table class="table-mb" v-loading="loading" :data="list" :header-cell-style="{ background: '#F5F7FA' }"
              element-loading-background="rgba(255, 255, 255, 0.6)" row-key="sid" @select="handleSelected" @select-all="handleAllSelected">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="operationType" label="操作" width="300">
        <template #default="{ row }">
          <div>
            <el-text type="info">业务模块名	：</el-text>
            <span>{{row.title}}</span>
          </div>
          <div>
            <el-text type="info">业务类型：</el-text>
            <span>{{row.businessType}}</span>
          </div>
          <div>
            <el-text type="info">操作类别：</el-text>
            <span>{{row.operationType	}}</span>
          </div>
          <div>
            <el-text type="info">操作时间：</el-text>
            <span>{{row.requestTime}}</span>
          </div>
          <div>
            <el-text type="info">状态：</el-text>
            <el-text v-if="row.status === 1" type="success">成功</el-text>
            <el-text v-else-if="row.status === 2" type="danger">失败</el-text>
            <el-text v-else type="info"></el-text>
          </div>
          <div>
            <el-text type="info">错误消息：</el-text>
            <span>{{row.errorMsg	}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column align="left" prop="requestMethod" label="请求">
        <template #default="{ row }">
          <div>
            <el-text type="info">请求url：</el-text>
            <span>{{row.requestUrl}}</span>
          </div>
          <div>
            <el-text type="info">请求方式：</el-text>
            <span>{{row.requestMethod}}</span>
          </div>

          <div>
            <el-text type="info">请求参数：</el-text>
            <span>{{row.requestParam}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="80" fixed="right">
        <template #default="{ row }">
          <el-popconfirm :persistent="false" title="确定删除吗？" confirm-button-text="确定" cancel-button-text="取消"
                         @confirm="handleDelete(row.sid)">
            <template #reference>
              <el-button link type="danger">删除</el-button>
            </template>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
        background
        v-model:current-page="page"
        v-model:page-size="pageSize"
        :page-sizes="pageSizeNum"
        :total="totalNums"
        layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>

    <go-back/>
  </div>
</template>

<script setup>
import {
  getCurrentInstance,
  ref,
  reactive,
  onMounted,
  watch,
  computed
} from "vue"
import listMixins from "@mixins/hook/list"
import {
  useRouter
} from "vue-router"
import {
  CirclePlus, Search
} from "@element-plus/icons-vue"
import GoBack from "@components/GoBack.vue"
import * as ElementPlusIconsVue from "@element-plus/icons-vue"


const router = useRouter()
const {
  proxy
} = getCurrentInstance()

/**
 * minxin列表加载
 */
const {
  page,
  pageSizeNum,
  pageSize,
  loading,
  totalNums,
  searchParams,
  searchBtnLoading,
  apiPath,
  list,
  dialogFormRef,
  dialogShow,
  dialogForm,
  dialogParams,
  handleSearch,
  getData,
  handleAdd,
  handleEdit,
  resetDialogForm,
  handleAllSelected,
  handleSelected,
  selectedIds,
  submitDialogForm,
  closeDialog,
  handleAction,
  handleDelete,
  sortFieldName
} = listMixins()

apiPath.value = '/logs/operation-logs';
sortFieldName.value = 'requestTime'

onMounted(() => {
  getData()
})
</script>

<style lang="less">

</style>